home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / wtek0693.zip / OOPALLEY.ZIP / POINT.CPP < prev    next >
C/C++ Source or Header  |  1993-04-27  |  891b  |  43 lines

  1. #include "point.h"
  2.  
  3. #define THIS Point
  4. #define BASE Object
  5. DEFINE_CLASS(Point,Object);
  6.  
  7. void Point::printOn(ostream& strm) const
  8. {
  9.     strm << "(" << xc << " @ " << yc << ")";
  10. }
  11.  
  12. Point Point::max(Point p) const
  13. {
  14.     return Point(MAX(xc,p.xc),MAX(yc,p.yc));
  15. }
  16.  
  17. Point Point::min(Point p) const
  18. {
  19.     return Point(MIN(xc,p.xc),MIN(yc,p.yc));
  20. }
  21.  
  22. bool Point::isEqual(const Object& p) const
  23. {
  24.     return p.isSpecies(class_Point) && *this==*(Point*)&p;
  25. }
  26.  
  27. const Class* Point::species() const  { return &class_Point; }
  28.  
  29. int Point::compare(const Object& p) const
  30. {
  31.     int t;
  32.     assertArgSpecies(p,class_Point,"compare");
  33.     if ((t=yc-((Point*)&p)->yc) != 0) return t;
  34.     else return (xc-((Point*)&p)->xc);
  35. }
  36.  
  37. unsigned Point::hash() const { return xc^yc; }
  38.  
  39. Object* Point::copy() const      { return shallowCopy(); }
  40.  
  41. void Point::deepenShallowCopy() {}
  42.  
  43.